﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufExtension.h"
#include "GnufItemEvents.h"
#include "GnufPallet.h"

namespace gcmp {
    class IFamilyTypeInfo;
}

namespace gnuf {

    class QtBnufFamilyOverrideStrategySelector;
    class Toolbar;
    class DropDownBoard;

    // 族加载
    class GNUF_EXTENSION_EXPORT GnufFamilyOverrideStrategySelector final
        : public IPalletEventHandler
        , public IItemEventHandler
    {
        CANNOT_COPY_OR_ASSIGN(GnufFamilyOverrideStrategySelector)
    public:
        explicit GnufFamilyOverrideStrategySelector(std::wstring& msg, const std::vector<const gcmp::IFamilyTypeInfo*>& familyTypeInfos);
        ~GnufFamilyOverrideStrategySelector();
        // 选中的族类型
        const gcmp::IFamilyTypeInfo* familyTypeInfo() const { return m_selectedFamilyTypeInfo; }

        gnuf::Toolbar* toolbar() { return m_toolbar.get(); }

        enum EResultCode {
            eReplace,
            eDelete,
            eCancel
        };
        EResultCode ResultCode() const { return m_resultCode; }
        GnufFamilyOverrideStrategySelector::EResultCode Show();

    protected:
        // Inherits from IPalletEventHandler...
        virtual void onHeaderButtonClicked(Pallet *) override;
        virtual bool onFooterButtonClicked(Pallet *) override;
        virtual bool onKeyEvent(Pallet *, IPalletEventHandler::EKey) override;
        virtual void onCurrentIndexChanged(DropDownBoard*, int, Item*)  override;

    private:
        void refreshStyle();

    private:
        QtBnufFamilyOverrideStrategySelector * m_qtSelector;
        EResultCode m_resultCode;
        std::wstring m_message;
        const gcmp::IFamilyTypeInfo* m_selectedFamilyTypeInfo;
        const std::vector<const gcmp::IFamilyTypeInfo*> m_familyTypeInfos;
        gcmp::OwnerPtr<gnuf::Toolbar> m_toolbar;
    };
}
